/****************************************************************************
 *
 * Copyright (C) 2003-2010 Los Alamos National Security, LLC
 *                         Packet Analytics Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 2 as
 * published by the Free Software Foundation.  You may not use, modify or
 * distribute this program under any other version of the GNU General
 * Public License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 ****************************************************************************/
package nfse.dataset.bluecoat;


import nfse.NetFSE;
import nfse.NetFSERecord;
import nfse.NetFSEUtil;

public class BlueCoatRecord extends NetFSERecord {
    
    long duration = 0;
    String status = "";
    String action = "";
    long dstBytes = -1;
    long srcBytes = -1;
    String method = "";
    String uriScheme = "";
    String dstHost = "";
    String proxyAddr = "";
    String uriStem = "";
    String userName = "";
    String authGroup = "";
    String hierarchy = "";
    String dstAddr = "";
    String contentType = "";
    String userAgent = "";
    String filterResult = "";
    String filterCategory = "";
    String virusID = "";
    String proxyAddrAgain = "";
    String siteName = "";
    int proxyPort = -1;
    
    @Override
    public long getDstIP() {
        if (dstAddr.length() == 0 || dstAddr.trim().equals("-"))
            return -1;
        long dstIP = -1;
        try {
            dstIP = NetFSEUtil.convertIPtoLong(dstAddr);
            if (dstIP == -1) {
                System.out.println("Bad IP: " + dstAddr);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dstIP;
    }

    @Override
    public int getDstPort() {
        return -1;
    }
    
    @Override
    public int[] getIndexedFields() {
        int[] temp = { NetFSE.FIELD_START_TS, NetFSE.FIELD_SRC_IP, NetFSE.FIELD_DST_IP };
        return temp;
    }
    
    /*******
     * There may be data in the records that needs to be hex-encoded when stored
     * in PostgreSQL. Store as hex instead of raw.
     */
    @Override
    public boolean hasBinary() {
        return true;
    }
    
}
